PROG=adcmana
LPROG=ladcmana
RPROG=radcmana

SVNVER=\"$(shell svnversion)\"

LFS=$(shell getconf LFS_CFLAGS)

#S1 = $(shell echo \#define SVNVERSION )
#S2 = $(shell svnversion)
#S3 = $(shell echo \")

LINK=g++
OPT=-O3 -Wall

CPPFLAGS += $(LFS) -D LINUX=1 -I.

ifdef ROOTSYS
  CPPFLAGS += -I$(shell $(ROOTSYS)/bin/root-config --incdir)
  CPPFLAGS += $(shell  $(ROOTSYS)/bin/root-config --cflags)
  LDLIBS   += $(shell  $(ROOTSYS)/bin/root-config --glibs) # -lXMLIO
endif


#%.o : src/%.cxx
#	$(CXX) $(CPPFLAGS) $(OSFLAGS) -o $@ -c $< 

#%.o : %.cxx
#	$(CXX) $(CPPFLAGS) $(OSFLAGS) -o $@ -c $< 

#.SUFFIXES: .cxx

all: clean svnver $(PROG)
long: clean svnver $(LPROG)
romash: clean svnver $(RPROG)

adc3Dict.o: adc3Dict.cxx
	$(CXX) $(CPPFLAGS) $(OSFLAGS) -o adc3Dict.o -c adc3Dict.cxx

$(PROG).o: src/$(PROG).cxx
	$(CXX) $(CPPFLAGS) $(OSFLAGS) -o $(PROG).o -c src/$(PROG).cxx

$(LPROG).o: src/$(PROG).cxx
	$(CXX) $(CPPFLAGS) -D LONGSTAMP=1 $(OSFLAGS) -o $(LPROG).o -c src/$(PROG).cxx

$(RPROG).o: src/$(PROG).cxx
	$(CXX) $(CPPFLAGS) -D LONGSTAMP=1 -D ROMASH=1 $(OSFLAGS) \
	-o $(RPROG).o -c src/$(PROG).cxx

svnver: Makefile
	echo \#define SVNVERSION $(SVNVER) >svn.h

#%.o : src/%.cxx
#	$(CXX) $(CPPFLAGS) $(OSFLAGS) -o $@ -c $< 

root2ascii.o: src/root2ascii.cxx
	$(CXX) $(CPPFLAGS) $(OSFLAGS) -o root2ascii.o -c src/root2ascii.cxx

adc3Dict: src/adcmana.h src/LinkDef.h
	rootcint -f adc3Dict.cxx -c src/adcmana.h src/LinkDef.h

$(PROG): adc3Dict $(PROG).o adc3Dict.o Makefile
	$(LINK) -o $(PROG).x $(PROG).o adc3Dict.o \
	$(LIBS) $(LDLIBS)

$(LPROG): adc3Dict $(LPROG).o adc3Dict.o Makefile
	$(LINK) -o $(LPROG).x $(LPROG).o adc3Dict.o \
	$(LIBS) $(LDLIBS)

$(RPROG): adc3Dict $(RPROG).o adc3Dict.o Makefile
	$(LINK) -o $(RPROG).x $(RPROG).o adc3Dict.o \
	$(LIBS) $(LDLIBS)

root2ascii: root2ascii.o Makefile
	$(LINK) -o root2ascii root2ascii.o $(LIBS) $(LDLIBS)

clean:
	rm -f *.x *.o *~ \#* *.d *.so *.obj *.exe adc3Dict.* svn.h
